<template>
  <div class="count-container">
    <div class="count-title">
      <p>数据统计</p>
      <img src="../../images/dataScreen-title.png" alt="暂无图片" />
    </div>
    <!-- 图表容器：要设置好宽高 -->
    <div ref="countRef" class="count-echart"></div>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from "vue";
import * as echarts from "echarts";
let countRef = ref();
onMounted(() => {
  const myEchart = echarts.init(countRef.value);
  myEchart.setOption({
    title: {
      text: "雷达图",
      textStyle: {
        color: "white",
      },
    },
    legend: {
      //   data: ["Allocated Budget", "Actual Spending"],
      orient: "vertical",
      top: 50,
      right: 36,
      textStyle: {
        color: "white",
        fontSize: 18,
      },
    },
    radar: { // 雷达
      // shape: 'circle',
      indicator: [
        { name: "消费", max: 6500 },
        { name: "好感", max: 16000 },
        { name: "出行", max: 30000 },
        { name: "小吃", max: 38000 },
        { name: "爱好", max: 52000 },
        { name: "景点", max: 25000 },
      ],
      center: ['42%', '50%'] // 中心位置
    },
    series: [ // 雷达系列
      {
        name: "预算 vs 消费",
        type: "radar",
        data: [
          {
            value: [4200, 3000, 20000, 35000, 50000, 18000],
            name: "预算",
          },
          {
            value: [5000, 14000, 28000, 26000, 42000, 21000],
            name: "消费",
          },
        ],
      },
    ],
  });
});
</script>

<style scoped lang="scss">
.count-container {
  flex: 1;
  background: url("../../images/dataScreen-main-rc.png") no-repeat;
  background-size: 100% 100%;
  .count-title {
    color: white;
    font-size: 20px;
  }
  .count-echart {
    height: calc(100% - 40px);
    width: 100%;
  }
}
</style>
